package com.bear.cmcc.NetTestHTTP.ui.view;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager.LayoutParams;
import android.widget.Button;
import android.widget.TextView;

import com.bear.cmcc.NetTestHTTP.R;
import com.bear.cmcc.NetTestHTTP.component.VillageBean;
import com.bear.cmcc.NetTestHTTP.util.MyCommonUtil;

public class DefineDialog extends Dialog {
	TextView tvCellName, tvAverageValue, tvDropRate, tvSignalValue, tvjietong,  tvCi;
	Button btnClose;

	public DefineDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
		super(context, cancelable, cancelListener);
	}

	public DefineDialog(Context context, int theme) {
		super(context, theme);
	}

	/**
	 * 布局创建
	 * 
	 * @param context
	 *            父容器
	 */
	public DefineDialog(Context context) {
		super(context, R.style.dialog_theme);
		setContentView(R.layout.layout_definedialog);
		btnClose = (Button) findViewById(R.id.btnClose);
		btnClose.setOnClickListener(new android.view.View.OnClickListener(){
			public void onClick(View v) {
				DefineDialog.this.dismiss();
			}
		});
		
		tvCellName = (TextView) findViewById(R.id.tvCellName);
		tvAverageValue = (TextView) findViewById(R.id.tvAverageValue);
		tvDropRate = (TextView) findViewById(R.id.tvDropRate);
		tvSignalValue = (TextView) findViewById(R.id.tvSignalValue);
		tvjietong = (TextView) findViewById(R.id.tvjietong);
		tvCi = (TextView) findViewById(R.id.tvCi);

		LayoutParams params = getWindow().getAttributes();
		params.gravity = Gravity.CENTER;

		getWindow().setAttributes(params);

	}
	
	public void setLayoutData(VillageBean villageBean){
		tvCellName.setText(villageBean.getVillage_name());
		tvAverageValue.setText(MyCommonUtil.getFormatString(villageBean.averageSpeed));
		tvDropRate.setText(String.valueOf(villageBean.droppingRate));
		tvSignalValue.setText(String.valueOf(villageBean.signalStrength));
		tvjietong.setText(String.valueOf(villageBean.getJietong()));
		tvCi.setText(String.valueOf(villageBean.getCi()));
	
	}


}
